package com.example.luo.toggle;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ToggleView view = (ToggleView) findViewById(R.id.toggleview);
        view.processOnToggleStateChanged(new ToggleView.OnToggleStateChanged() {
            @Override
            public void openOrClose(ToggleView toggle, boolean isOpened) {
                if (isOpened) {
                    Toast.makeText(MainActivity.this, "开关关闭了", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(MainActivity.this, "开关打开了", Toast.LENGTH_SHORT).show();
                }
            }
        });

    }

}
